package util.io;

import java.io.File;
import java.util.LinkedList;

public class DirectoryInput {

	/**
	 * @param args
	 */
	
	
	/**
	 * 
	 * List files in a directory - no recursive
	 * 
	 * 
	 * 
	 * 
	 */
	public static LinkedList<String> listDirectory(String path, String filter) {

		File dir = new File(path);
		String[] children = dir.list();

		LinkedList<String> files = new LinkedList<String>();
		if (children == null) {
			return null;
		} else {
			for (int i = 0; i < children.length; i++) {
				// Get filename of file or directory
				String filename = children[i];
				
				
				if(filename.endsWith(filter)){
					if(!path.endsWith("/")){
						path = path+ "/";
					}

					files.add(path +filename);
				//	System.out.println(path +filename);
					
				}
				
				
			}

		}

		return files;

	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
